package com.taldh.design.patterns.observer.impl;

import java.util.ArrayList;
import java.util.List;

/**
 * date 2020/5/26
 *
 * @author 袁小黑
 * @version 1.0.0
 **/

class Weather extends Observable<Weather, Dahuaxiyou , WeatherType> {

    private WeatherType currentWeather;

    public Weather() {
        currentWeather = WeatherType.SUNNY;
        System.out.println("Init weather is"+currentWeather);
        this.addObserver(new Sunwukong());
        this.addObserver(new Tangseng());
    }

    public void timePasses() {
        WeatherType[] enumValues = WeatherType.values();
        currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length];
        System.out.println("The weather changed to "+currentWeather);
        notifyObservers(currentWeather);
    }

}
